$(document).ready( function() {
	  var table = $('table#dailyReportTable').DataTable({
          initComplete: function(settings, json) {
              $("#dailyReportTable").removeClass('dataTable');
              $("#dailyReportTable").parent().addClass('table-responsive');

              $("#dailyReportTable").parent().height($(window).height()-$('#query-area').height()-230);

              $("#dailyReportTable").on('change', 'input[type="checkbox"]', function () {
                  if($(this).prop('checked')) {
                      $(this).closest('tr').addClass('warning');
                  } else {
                      $(this).closest('tr').removeClass('warning');
                  }
              });
          },
	    ajax: {
	      url: baseUrl + '/dailyinboundDatatable',
	      data : function(d) {
			d.transDate = $("#transDate").val();
			return d;
	      }
	    },
	    order: [
	      [1, 'asc']
	    ],
	    columns: [{
	      name: 'opentime',
	      data: 'opentime'
	    },{
	      name: 'materialcode',
	      data: 'materialcode'
	    },{
	      name: 'materialname',
	      data: 'materialname'
	    },{
	      name: 'lotnumber',
	      data: 'lotnumber'
	    },{
	      name: 'summcontaincount',
		  data: 'summcontaincount'
	    },{
		  name: 'summquantity',
		  data: 'summquantity'
	    }]
	  });
	  
		$('.form_datetime').datetimepicker({
	        format: 'yyyy-mm-dd',
	         weekStart: 1,  
	         autoclose: true,  
	         startView: 2,  
	         minView: 2,  
	         forceParse: false,  
	         language: 'cn',
		     calendarWeeks: true,
		     pickerPosition: "bottom-left"
	    }).on('changeDate', function (ev) {
	        daycount = 0;
	        if (null != ev.date && undefined != ev.date) {
	        	var day = new Date(ev.date.getYear(), ev.date.getMonth(),ev.date.getDate());
		        daycount = day.getDate();
	        }
	        
	    });
		


		  //导出 动态组织form提交
		  $(".btn.export").on("click", function (e) {
			$("#exportForm .param").remove();
			var $frm = $("#exportForm");
		　　　var array = $('.search-form').serializeArray();
		　　　for (i = 0, length = array.length; i < length; i++) {
			　　　key = array[i].name;
				value = array[i].value;
				$frm.append($('<input class="param" type="hidden" name = "' + key + '" value = "' + value + '" />')); 
			}
			var params = table.ajax.params();
			$frm.append($('<input class="param" type="hidden" name="input" value = \'' + JSON.stringify(params) + '\' />')); 
			$frm.submit();
			// 阻止默认行为
			e.preventDefault();
			return false;  
		  });
		  
	  $('.search-form').on("submit", function (e) {
	    table.draw();
	    //阻止表单submit
	    return false;
	  });
	
});
